import React, { Component } from 'react';
import {
    StyleSheet,
    View,
    Text,
    Image,
    TouchableOpacity,
    Dimensions,
    ScrollView, StatusBar,
} from 'react-native';
import { WebView } from 'react-native-webview';
// 取得屏幕的宽高Dimensions
import app from '../../../app.json';
import Ugame from '../../../Ugame';
import Httpc from "../../utils/Httpc";
import REQUEST from "../../../REQUEST";
import Football from "../../utils/Football";
import Utils from "../../utils/Utils";
const { width, height } = Dimensions.get('window')


export default class NewsDetailed extends Component {
    constructor(props) {
        super(props);
        this.state = {
            deatiled: null,
        };
    }
    static navigationOptions = {
        title: '资讯详细',
        //header: null,  //隐藏顶部导航栏
        //tabBarVisible: false, // 隐藏底部导航栏
        headerStyle: {
            backgroundColor: '#d0162e',
            paddingTop: 18
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
            //fontWeight: 'bold',
        },
    }
    componentDidMount() {
        const { navigation } = this.props;
        this.id = navigation.getParam("id");
        this.getServerData(() => { });
    }
    getServerData(callback) {
        let params = {};
        params.id = this.id;
        Httpc.get(REQUEST.GetNewDetail, params, (res) => {
            if (res.StatusCode == 1) {
                this.setState({
                    deatiled: res.Data
                })
            }
            callback();
        })
    }
    renderLoadingView() {
        return (
            <View style={styles.container}>
                <Text>Loading movies...</Text>
            </View>
        );
    }
    render() {
        let { deatiled } = this.state;
        if (deatiled == null) {
            return this.renderLoadingView();
        }
        var html="<html><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=0'>"+           
            "<style type='text/css'> body{padding-left:16;padding-right:16; margin:0;} img{width:100%}</style></head>"+    
            "<body style='height:200px;'><div style='font-size:20;padding-top:10px;padding-bottom:10px' >"+deatiled.title+"</div><div style='padding-bottom:10px' >"+(!!deatiled.ctime ? deatiled.ctime.substr(0, 10) : null)+"</div><div>"+deatiled.content+"</div></body></html>" ;      

        return (
            <View style={styles.container}>
                <StatusBar translucent={true} backgroundColor="transparent" />
                <ScrollView style={{ width: width, height: height }}>
                    <WebView
                        originWhitelist={['*']}
                        source={{ html:html}}
                        

                        style={{width:width,height:height-70}}
                    />
                </ScrollView>
            </View>
        );
    }
}
const styles = StyleSheet.create({
    container: {
        flex: 1,
        alignItems: 'center',
        backgroundColor: '#fff',
    },
});